package base.thread;

public class DaemonTest {

	public static void main(String[] args) throws InterruptedException {
		
		MyThread t1 = new MyThread();
		t1.start();
		MyDaemonThread t2 = new MyDaemonThread();
		t2.setDaemon(true);
		t2.start();
		/*int i=1;
		while(t2.isAlive()) {
			Thread.sleep(1000);
			System.out.println("MyDaemonThread is alive");
			System.out.println(i);
			i++;
		}*/
	}
}

class MyThread extends Thread{

	@Override
	public void run() {
		
		for(int i=1; i<=10; i++) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
		System.out.println("MyThread over");
	}
	
}


class MyDaemonThread extends Thread{

	@Override
	public void run() {
		for(int i=1; i<=100; i++) {
			try {
				Thread.sleep(1000);
				System.out.println("this is MyDaemonThread");
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
}